﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;

namespace Moe_v0._1
{
    class StructuredSentence
    {
        private List<SubSentence> _struturedSentence = null;
        private string _originalInput = "";
        private char[] _punctuations = EnSegmentor.PunctuationsString.ToCharArray();
        private string _subSentencePattern = "([^" + EnSegmentor.PunctuationsString + "]+"
            + "[" + EnSegmentor.PunctuationsString + "]?)";
        public StructuredSentence(string input)
        {
            _originalInput = input;
            input = input.ToLower();
            if (MoeDebugger.IsDebugging)
            {
                MoeDebugger.AddDebugInfo(
                    "StruturedSentence: " + "pattern of sub sentence is: " + _subSentencePattern);
            }

            _struturedSentence = new List<SubSentence>();
            foreach(Match match in Regex.Matches(input, _subSentencePattern))
            {
                _struturedSentence.Add(new SubSentence(match.Value));
                if (MoeDebugger.IsDebugging)
                {
                    MoeDebugger.AddDebugInfo("StruturedSentence: <sub sentence match by regex>" + match.Value);
                }
            }

            if (MoeDebugger.IsDebugging)
            {
                MoeDebugger.AddDebugInfo(
                    "StructuredSentence: " + _struturedSentence.Count.ToString()
                    + " sub sentence is matched.");
            }
        }

        public List<SubSentence> SubSentences
        {
            get
            {
                Debug.Assert(_struturedSentence != null);
                return _struturedSentence;
            }
        }
    }
}
